#include <iostream>
#include "Student.h"
#include "GlobalData.h"


int main() {
    while(true){
        cout<<"请选择登录类型"<<endl;
        cout<<"1.教师"<<endl;
        cout<<"2.学生"<<endl;
        cout<<"3.退出"<<endl;
        int loginType;
        cin >> loginType;
        if (loginType == 3)
            break;

        if (loginType == 2){
            cout<<"请输入学号"<<endl;
            string stuNo;
            cin>>stuNo;
            cout<<"请输入密码"<<endl;
            string stuPsw;
            cin>>stuPsw;
            CStudent* student = GlobalData::userManager.StudentLogin(stuNo, stuPsw);
            if (student == NULL)
                break;
            student->DoFunction();
        }
        if (loginType == 1){
            cout<<"请输入教师账号ID"<<endl;
            int teacherId;
            cin>>teacherId;
            cout<<"请输入密码"<<endl;
            string teacherPsw;
            cin>>teacherPsw;
            CTeacher* teacher = GlobalData::userManager.TeacherLogin(teacherId, teacherPsw);
            if (teacher == NULL){
                cout<<"密码错误"<<endl;
                break;
            }
            teacher->DoFunction();
        }
    }
}
